home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / sendmail / sendmail-5.65c+IDA-1.4.4.1 / src / RCS / stats.c,v < prev    next >
Encoding:
Text File  |  1991-06-25  |  4.4 KB  |  237 lines

  1. head    5.11;
  2. branch    5.11.0;
  3. access;
  4. symbols
  5.     RELEASE:5.11.0.5
  6.     BETA:5.11.0.4
  7.     UICSO:5.11.0
  8.     VANILLA:5.11;
  9. locks; strict;
  10. comment    @ * @;
  11.  
  12.  
  13. 5.11
  14. date    90.06.20.08.37.07;    author paul;    state Exp;
  15. branches
  16.     5.11.0.1;
  17. next    ;
  18.  
  19. 5.11.0.1
  20. date    91.02.17.22.58.53;    author paul;    state Exp;
  21. branches;
  22. next    5.11.0.2;
  23.  
  24. 5.11.0.2
  25. date    91.03.04.21.48.23;    author paul;    state Exp;
  26. branches;
  27. next    5.11.0.3;
  28.  
  29. 5.11.0.3
  30. date    91.04.05.14.55.15;    author paul;    state Exp;
  31. branches;
  32. next    5.11.0.4;
  33.  
  34. 5.11.0.4
  35. date    91.05.18.18.25.39;    author paul;    state Exp;
  36. branches;
  37. next    5.11.0.5;
  38.  
  39. 5.11.0.5
  40. date    91.06.24.20.27.43;    author paul;    state Exp;
  41. branches;
  42. next    ;
  43.  
  44.  
  45. desc
  46. @@
  47.  
  48.  
  49.  
  50. 5.11
  51. log
  52. @5.64 Berkeley release
  53. @
  54. text
  55. @/*
  56.  * Copyright (c) 1983 Eric P. Allman
  57.  * Copyright (c) 1988 Regents of the University of California.
  58.  * All rights reserved.
  59.  *
  60.  * Redistribution and use in source and binary forms are permitted provided
  61.  * that: (1) source distributions retain this entire copyright notice and
  62.  * comment, and (2) distributions including binaries display the following
  63.  * acknowledgement:  ``This product includes software developed by the
  64.  * University of California, Berkeley and its contributors'' in the
  65.  * documentation or other materials provided with the distribution and in
  66.  * all advertising materials mentioning features or use of this software.
  67.  * Neither the name of the University nor the names of its contributors may
  68.  * be used to endorse or promote products derived from this software without
  69.  * specific prior written permission.
  70.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  71.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  72.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  73.  */
  74.  
  75. #ifndef lint
  76. static char sccsid[] = "@@(#)stats.c    5.11 (Berkeley) 6/1/90";
  77. #endif /* not lint */
  78.  
  79. # include "sendmail.h"
  80. # include "mailstats.h"
  81.  
  82. struct statistics    Stat;
  83.  
  84. #define ONE_K        1000        /* one thousand (twenty-four?) */
  85. #define KBYTES(x)    (((x) + (ONE_K - 1)) / ONE_K)
  86. /*
  87. **  MARKSTATS -- mark statistics
  88. */
  89.  
  90. markstats(e, to)
  91.     register ENVELOPE *e;
  92.     register ADDRESS *to;
  93. {
  94.     if (to == NULL)
  95.     {
  96.         if (e->e_from.q_mailer != NULL)
  97.         {
  98.             Stat.stat_nf[e->e_from.q_mailer->m_mno]++;
  99.             Stat.stat_bf[e->e_from.q_mailer->m_mno] +=
  100.                 KBYTES(CurEnv->e_msgsize);
  101.         }
  102.     }
  103.     else
  104.     {
  105.         Stat.stat_nt[to->q_mailer->m_mno]++;
  106.         Stat.stat_bt[to->q_mailer->m_mno] += KBYTES(CurEnv->e_msgsize);
  107.     }
  108. }
  109. /*
  110. **  POSTSTATS -- post statistics in the statistics file
  111. **
  112. **    Parameters:
  113. **        sfile -- the name of the statistics file.
  114. **
  115. **    Returns:
  116. **        none.
  117. **
  118. **    Side Effects:
  119. **        merges the Stat structure with the sfile file.
  120. */
  121.  
  122. poststats(sfile)
  123.     char *sfile;
  124. {
  125.     register int fd;
  126.     struct statistics stat;
  127.     extern off_t lseek();
  128.  
  129.     if (sfile == NULL)
  130.         return;
  131.  
  132.     (void) time(&Stat.stat_itime);
  133.     Stat.stat_size = sizeof Stat;
  134.  
  135.     fd = open(sfile, 2);
  136.     if (fd < 0)
  137.     {
  138.         errno = 0;
  139.         return;
  140.     }
  141.     if (read(fd, (char *) &stat, sizeof stat) == sizeof stat &&
  142.         stat.stat_size == sizeof stat)
  143.     {
  144.         /* merge current statistics into statfile */
  145.         register int i;
  146.  
  147.         for (i = 0; i < MAXMAILERS; i++)
  148.         {
  149.             stat.stat_nf[i] += Stat.stat_nf[i];
  150.             stat.stat_bf[i] += Stat.stat_bf[i];
  151.             stat.stat_nt[i] += Stat.stat_nt[i];
  152.             stat.stat_bt[i] += Stat.stat_bt[i];
  153.         }
  154.     }
  155.     else
  156.         bcopy((char *) &Stat, (char *) &stat, sizeof stat);
  157.  
  158.     /* write out results */
  159.     (void) lseek(fd, (off_t) 0, 0);
  160.     (void) write(fd, (char *) &stat, sizeof stat);
  161.     (void) close(fd);
  162. }
  163. @
  164.  
  165.  
  166. 5.11.0.1
  167. log
  168. @ANSIfied.
  169. @
  170. text
  171. @a35 1
  172. void
  173. a67 1
  174. void
  175. d69 1
  176. a69 1
  177.     const char *sfile;
  178. d73 1
  179. @
  180.  
  181.  
  182. 5.11.0.2
  183. log
  184. @ANSIfied.
  185. @
  186. text
  187. @d71 1
  188. a71 1
  189.     char *sfile;
  190. @
  191.  
  192.  
  193. 5.11.0.3
  194. log
  195. @Added RCS ID string
  196. @
  197. text
  198. @a22 1
  199. static char  rcsid[] = "@@(#)$Id$";
  200. @
  201.  
  202.  
  203. 5.11.0.4
  204. log
  205. @Now stores message lengths in unsigned number of bytes.  Part of the
  206. System 5 and general improvement patches contributed by Bruce Lilly
  207. (bruce%balilly@@broadcast.sony.com).
  208. @
  209. text
  210. @d22 2
  211. a23 2
  212. static char sccsid[] = "@@(#)stats.c    5.11 (Berkeley) 6/1/90    %I% local";
  213. static char  rcsid[] = "@@(#)$Id: stats.c,v 5.11.0.3 1991/04/05 14:55:15 paul Exp paul $";
  214. d31 2
  215. d47 2
  216. a48 1
  217.             Stat.stat_bf[e->e_from.q_mailer->m_mno] += CurEnv->e_msgsize;
  218. d54 1
  219. a54 1
  220.         Stat.stat_bt[to->q_mailer->m_mno] += CurEnv->e_msgsize;
  221. d80 1
  222. a80 1
  223.     (void) time((TIME_TYPE *) &Stat.stat_itime);
  224. @
  225.  
  226.  
  227. 5.11.0.5
  228. log
  229. @editted sccsid.
  230. @
  231. text
  232. @d22 2
  233. a23 2
  234. static char sccsid[] = "@@(#)stats.c    5.11 (Berkeley) 6/1/90";
  235. static char  rcsid[] = "@@(#)$Id: stats.c,v 5.11.0.4 1991/05/18 18:25:39 paul Exp paul $";
  236. @
  237.